<?php
/**
 * Description:
 * User: Administrator
 * Date: 2017-06-16
 * Time: 14:16
 */

namespace app\backend\controller;
use app\backend\controller\traits\IncomeNoticeList;
use Business\CMBC\CmbcSDK;
use think\Controller;

class CmbcPayController extends Controller
{
    use IncomeNoticeList;
    private $_memberId = null;
    private $_dtype    = null;
    public function __construct()
    {
        parent::__construct();
        $memberInfo = $this->getLoginInfo();
        $this->_memberId = $memberInfo['mid'];
        $this->_dtype    = $memberInfo['dtype'];
    }
    public function Query()
    {
        if ($this->_memberId != 117) {
            $this->apiReturn(206, [], '此接口已关闭，请稍后重试');
        }
        $ordernum       = I('ordernum');
        $trade_type     = I('trade_type', 1);
        $orgvoucherNo   = I('orgvoucherNo', '');
        $ordernum='B149559729482201703012017030918100';$trade_type=2;$orgvoucherNo='000000224213';
        $minsheng = new CmbcSDK();
        $res = $minsheng->Query($ordernum, $trade_type, $orgvoucherNo);
        $this->apiReturn(200, $res, '');
    }
    public function Refund()
    {
        if ($this->_memberId != 117) {
            $this->apiReturn(206, [], '此接口已关闭，请稍后重试');
        }
        $ordernum       = I('post.ordernum');
        $amount         = I('post.amount');//分为单位
        $orderNote      = I('post.orderNote', '');
        $ordernum='B149559729482201703012017030918100';$amount=1;$orderNote='我要退款';
        $minsheng = new CmbcSDK();
        $res = $minsheng->Refund($ordernum, $amount, $orderNote);
        if ($res['tradeStatus']==='S') {
            $res['msg']='退款成功了';
        }
        $this->apiReturn(200, $res, '');
    }
}